a=int(input())
m=int(input())
c=int(input())
def runyear(a):
    if (a%4==0 and a%100!=0) or (a%400==0):
        return Ture
    else:
        return False
if m in [4,6,9,11]:
    d=30
elif m==2:
    if runyear(a):
        d=29
    else:
        d=28
else:
    d=31
e=d-c
print(e)